﻿<div class="text-center">
    <MButton Disabled="dialog"
             Loading="dialog"
             Class="white--text"
             Color="purple darken-2"
             OnClick="()=>dialog = true">
        Start loading
    </MButton>
    <MDialog @bind-Value="dialog"
             Persistent
             Width="300">
        <MCard Color="primary"
               Dark>
            <MCardText>
                Please stand by
                <MProgressLinear Indeterminate
                                 Color="white"
                                 Class="mb-0"></MProgressLinear>
            </MCardText>
        </MCard>
    </MDialog>
</div>

@code {
    bool dialog = false;
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (dialog)
        {
            await Task.Delay(4000);
            dialog = false;

            StateHasChanged();
        }
    }
}